package com.microblogforsim.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.microblogforsim.R;
import com.microblogforsim.model.User_History_Item;

import java.util.ArrayList;

public class UserHistoryAdapter extends BaseAdapter {
    private Context context;
    private ArrayList<User_History_Item> items;

    public UserHistoryAdapter(Context context, ArrayList<User_History_Item> items) {
        this.context = context;
        this.items = items;
    }

    @Override
    public int getCount() {
        return items.size();
    }

    @Override
    public Object getItem(int position) {
        return items.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = View.inflate(context, R.layout.item_user_history_list,null);
        ImageView iv_img = convertView.findViewById(R.id.item_user_history_img);
        TextView tv_title = convertView.findViewById(R.id.item_user_history_title);
        iv_img.setImageResource(items.get(position).getImg());
        tv_title.setText(items.get(position).getTitel());
        return convertView;
    }
}
